﻿using MainInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace MainFrameProperty
{
    public class UIProperty : IComponentXml,IBuilder
    {
        public string Name { get; set; }
        public object Value { get; set; }
        public string ChinaName { get; set; }
        public string GroupName { get; set; }
        public string Description { get; set; }
        public string DefaultValue { get; set; }
        public string Type { get; set; }
        public void LoadXmlZYK(System.Xml.XmlNode node)
        {
            XmlAttribute attr=node.Attributes["Type"];
            this.Type=attr.Value.ToLower();
            attr = node.Attributes["Name"];
            this.Name = attr.Value;
            attr = node.Attributes["ChinaName"];
            this.ChinaName = attr.Value;
            attr = node.Attributes["GroupName"];
            this.GroupName = attr.Value;
            attr = node.Attributes["Description"];
            this.Description = attr.Value;
            attr = node.Attributes["DefaultValue"];
            if (attr != null)
            {
                this.DefaultValue = attr.Value;
            }
            this.Value = PropertyValue.GetValue(this.Type, this.DefaultValue);
        }

        public void GetXml(System.Xml.XmlDocument doc, System.Xml.XmlNode Parent)
        {
            throw new NotImplementedException();
        }

        public void LoadUI(System.Xml.XmlNode node)
        {
            throw new NotImplementedException();
        }

        public string GetDom(string dom)
        {
            return string.Empty;
        }

        public string GetCSS(string style)
        {
            return string.Empty;
        }

        public string GetScript(string script)
        {
            string tem = string.Empty;            
            if (this.Value == null) 
            {
                return tem;
            }
            string valtem = this.Value.ToString();
            if (!string.IsNullOrEmpty(valtem))
            {
                if (Type == "string" || Type == "number")
                {
                    tem = "obj." + this.Name + "='" + valtem + "';";
                }
                else if (Type == "boolean")
                {
                    tem = "obj." + this.Name + "=" + valtem.ToLower() + ";";
                }
            }
            return tem;
        }


        public string GetReferences(string reference)
        {
            return string.Empty;
        }
        public string GetLinks(string links)
        {
            return string.Empty;
        }


        public void GetFiles(List<string> files)
        {
            return;
        }
    }
}
